﻿using System;
using System.Collections.Generic;

namespace UltimateFracturing
{
	// Token: 0x0200043F RID: 1087
	public class MeshDataConnectivity
	{
		// Token: 0x06001E6B RID: 7787 RVA: 0x000C2085 File Offset: 0x000C0285
		public MeshDataConnectivity()
		{
			this.dicHash2FaceList = new Dictionary<int, List<MeshDataConnectivity.Face>>();
			this.dicFace2HashList = new Dictionary<MeshDataConnectivity.Face, List<int>>(new MeshDataConnectivity.Face.EqualityComparer());
			this.dicFace2IsClipped = new Dictionary<MeshDataConnectivity.Face, bool>(new MeshDataConnectivity.Face.EqualityComparer());
		}

		// Token: 0x06001E6C RID: 7788 RVA: 0x000C20B8 File Offset: 0x000C02B8
		public MeshDataConnectivity GetDeepCopy()
		{
			MeshDataConnectivity meshDataConnectivity = new MeshDataConnectivity();
			foreach (KeyValuePair<int, List<MeshDataConnectivity.Face>> keyValuePair in this.dicHash2FaceList)
			{
				meshDataConnectivity.dicHash2FaceList.Add(keyValuePair.Key, new List<MeshDataConnectivity.Face>());
				foreach (MeshDataConnectivity.Face item in keyValuePair.Value)
				{
					meshDataConnectivity.dicHash2FaceList[keyValuePair.Key].Add(item);
				}
			}
			foreach (KeyValuePair<MeshDataConnectivity.Face, List<int>> keyValuePair2 in this.dicFace2HashList)
			{
				meshDataConnectivity.dicFace2HashList.Add(keyValuePair2.Key, new List<int>());
				foreach (int item2 in keyValuePair2.Value)
				{
					meshDataConnectivity.dicFace2HashList[keyValuePair2.Key].Add(item2);
				}
			}
			foreach (KeyValuePair<MeshDataConnectivity.Face, bool> keyValuePair3 in this.dicFace2IsClipped)
			{
				meshDataConnectivity.dicFace2IsClipped.Add(keyValuePair3.Key, keyValuePair3.Value);
			}
			return meshDataConnectivity;
		}

		// Token: 0x06001E6D RID: 7789 RVA: 0x000C22A8 File Offset: 0x000C04A8
		public void NotifyNewClippedFace(MeshData meshDataSource, int nSourceSubMesh, int nSourceFaceIndex, int nDestSubMesh, int nDestFaceIndex)
		{
			MeshDataConnectivity.Face key = new MeshDataConnectivity.Face(nSourceSubMesh, nSourceFaceIndex);
			MeshDataConnectivity.Face face = new MeshDataConnectivity.Face(nDestSubMesh, nDestFaceIndex);
			if (meshDataSource.meshDataConnectivity.dicFace2HashList.ContainsKey(key))
			{
				foreach (int num in meshDataSource.meshDataConnectivity.dicFace2HashList[key])
				{
					if (!this.dicHash2FaceList.ContainsKey(num))
					{
						this.dicHash2FaceList.Add(num, new List<MeshDataConnectivity.Face>());
					}
					if (!this.dicFace2HashList.ContainsKey(face))
					{
						this.dicFace2HashList.Add(face, new List<int>());
					}
					this.dicHash2FaceList[num].Add(face);
					this.dicFace2HashList[face].Add(num);
					if (!this.dicFace2IsClipped.ContainsKey(face))
					{
						this.dicFace2IsClipped.Add(face, true);
					}
					else
					{
						this.dicFace2IsClipped[face] = true;
					}
				}
			}
		}

		// Token: 0x06001E6E RID: 7790 RVA: 0x000C23CC File Offset: 0x000C05CC
		public static int GetNewHash()
		{
			int result = 0;
			object typeFromHandle = typeof(MeshDataConnectivity);
			lock (typeFromHandle)
			{
				result = MeshDataConnectivity.s_CurrentSharedFaceHash;
				MeshDataConnectivity.s_CurrentSharedFaceHash++;
			}
			return result;
		}

		// Token: 0x06001E6F RID: 7791 RVA: 0x000C241C File Offset: 0x000C061C
		public void NotifyNewCapFace(int nHash, int nSubMesh, int nFaceIndex)
		{
			MeshDataConnectivity.Face face = new MeshDataConnectivity.Face(nSubMesh, nFaceIndex);
			if (!this.dicHash2FaceList.ContainsKey(nHash))
			{
				this.dicHash2FaceList.Add(nHash, new List<MeshDataConnectivity.Face>());
			}
			this.dicHash2FaceList[nHash].Add(face);
			if (!this.dicFace2HashList.ContainsKey(face))
			{
				this.dicFace2HashList.Add(face, new List<int>());
			}
			this.dicFace2HashList[face].Add(nHash);
		}

		// Token: 0x06001E70 RID: 7792 RVA: 0x000C249C File Offset: 0x000C069C
		public void NotifyRemappedFace(MeshDataConnectivity source, int nSourceSubMesh, int nSourceFaceIndex, int nDestSubMesh, int nDestFaceIndex)
		{
			MeshDataConnectivity.Face key = new MeshDataConnectivity.Face(nSourceSubMesh, nSourceFaceIndex);
			MeshDataConnectivity.Face face = new MeshDataConnectivity.Face(nDestSubMesh, nDestFaceIndex);
			if (source.dicFace2HashList.ContainsKey(key))
			{
				foreach (int num in source.dicFace2HashList[key])
				{
					if (!this.dicHash2FaceList.ContainsKey(num))
					{
						this.dicHash2FaceList.Add(num, new List<MeshDataConnectivity.Face>());
					}
					if (!this.dicFace2HashList.ContainsKey(face))
					{
						this.dicFace2HashList.Add(face, new List<int>());
					}
					this.dicHash2FaceList[num].Add(face);
					this.dicFace2HashList[face].Add(num);
					if (source.dicFace2IsClipped.ContainsKey(key))
					{
						if (!this.dicFace2IsClipped.ContainsKey(face))
						{
							this.dicFace2IsClipped.Add(face, true);
						}
						else
						{
							this.dicFace2IsClipped[face] = true;
						}
					}
				}
			}
		}

		// Token: 0x04001EEE RID: 7918
		public static int s_CurrentSharedFaceHash;

		// Token: 0x04001EEF RID: 7919
		public Dictionary<int, List<MeshDataConnectivity.Face>> dicHash2FaceList;

		// Token: 0x04001EF0 RID: 7920
		public Dictionary<MeshDataConnectivity.Face, List<int>> dicFace2HashList;

		// Token: 0x04001EF1 RID: 7921
		public Dictionary<MeshDataConnectivity.Face, bool> dicFace2IsClipped;

		// Token: 0x02000440 RID: 1088
		public struct Face
		{
			// Token: 0x06001E72 RID: 7794 RVA: 0x000C25C8 File Offset: 0x000C07C8
			public Face(int nSubMesh, int nFaceIndex)
			{
				this.nSubMesh = nSubMesh;
				this.nFaceIndex = nFaceIndex;
			}

			// Token: 0x04001EF2 RID: 7922
			public int nSubMesh;

			// Token: 0x04001EF3 RID: 7923
			public int nFaceIndex;

			// Token: 0x02000441 RID: 1089
			public class EqualityComparer : IEqualityComparer<MeshDataConnectivity.Face>
			{
				// Token: 0x06001E74 RID: 7796 RVA: 0x000C25D8 File Offset: 0x000C07D8
				public bool Equals(MeshDataConnectivity.Face x, MeshDataConnectivity.Face y)
				{
					return x.nSubMesh == y.nSubMesh && x.nFaceIndex == y.nFaceIndex;
				}

				// Token: 0x06001E75 RID: 7797 RVA: 0x000C2600 File Offset: 0x000C0800
				public int GetHashCode(MeshDataConnectivity.Face x)
				{
					return x.nSubMesh.GetHashCode() + x.nFaceIndex.GetHashCode();
				}
			}
		}
	}
}
